package com.mt.api.modules.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mt.api.constants.enums.OutStoreStatusEnum;
import com.mt.api.core.page.PageFactory;
import com.mt.api.modules.domain.OutStore;
import com.mt.api.modules.domain.bo.AppOutStorePageBo;
import com.mt.api.modules.manager.IOutStoreManager;
import com.mt.api.modules.mapper.OutStoreMapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: plover
 * @Date: 2022-05-30
 * @Description:
 */
@Component
public class OutStoreManagerImpl extends ServiceImpl<OutStoreMapper, OutStore> implements IOutStoreManager {


    @Override
    public List<OutStore> getListByOrderId(Integer orderId) {
        LambdaQueryWrapper<OutStore> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(OutStore::getOrderId, orderId)
                .eq(OutStore::getStatus, OutStoreStatusEnum.FINISHED.getCode());
        return baseMapper.selectList(wrapper);
    }

    @Override
    public Page<OutStore> getOutStorePage(AppOutStorePageBo bo) {
        Page page = PageFactory.defaultPage(bo);
        return baseMapper.getOutStorePage(page, bo);
    }
}
